package com.dofun.locationservice.util;

import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface.OnClickListener;

public class DialogUtils {
	
	private Context context;
	private String tittle;
	private int tittleId;
	private AlertDialog.Builder dialog;
	
	private int yourChoice = -1;
	private String inputStr;
	
	public DialogUtils(Context context, String tittle){
		this.context = context;
		this.tittle = tittle;
		dialog = new AlertDialog.Builder(context);
		dialog.setTitle(tittle);
	}
	
	public DialogUtils(Context context, int tittle){
		this.context = context;
		this.tittleId = tittle;
		dialog = new AlertDialog.Builder(context);
		dialog.setTitle(tittleId);
	}

	public void hintDialog(String msg, int positiveTextId, OnClickListener positiveListener){
		dialog.setMessage(msg);
		dialog.setPositiveButton(positiveTextId == 0? android.R.string.yes:positiveTextId, positiveListener)
				.create().show();
	}

	public void nomalDialog(int positiveTextId, OnClickListener positiveListener
			,int negativeTextId, OnClickListener negativeListener){
		dialog.setPositiveButton(positiveTextId == 0? android.R.string.yes:positiveTextId, positiveListener)
				.setNegativeButton(negativeTextId == 0?android.R.string.no:negativeTextId, negativeListener)
				.create().show();
	}

	public void nomalDialog(int positiveTextId, OnClickListener positiveListener){
		dialog.setPositiveButton(positiveTextId == 0? android.R.string.yes:positiveTextId, positiveListener)
				.create().show();
	}

	/**
	 * 
	 * @Author zs.Guo
	 * @Title: singleChoiceDialog
	 * @Description: ��ѡ�Ի���
	 * @param @param items: String[]
	 * @param @param choiceMode: default choice index
	 * @param @param listener
	 * @param @param positiveListener
	 * @return void
	 */
	public void singleChoiceDialog(String[] items, int choiceIndex, OnClickListener listener, OnClickListener positiveListener){
		dialog.setSingleChoiceItems(items, choiceIndex, listener);
		dialog.setPositiveButton(android.R.string.ok, positiveListener);
		dialog.show();
	}
	
}
